//
//  GoodBtn.m
//  gif
//
//  Created by Echo on 13-10-16.
//  Copyright (c) 2013年 Echo. All rights reserved.
//

#import "GoodBtn.h"
#import "GoodLabel.h"
#import "Global.h"

@implementation GoodBtn
+(instancetype)btnWithFont:(int)font;
{
    // create button instance
    GoodBtn *button = [[GoodBtn alloc] init];
    button.backgroundColor = [UIColor clearColor];
    button.titleLabel.font = [UIFont systemFontOfSize:font];
    return button;
}
+(instancetype)btnWithImg:(NSString*)imgStr;
{
    // create button instance
    UIImage *IMAGE = IMG(imgStr);
    GoodBtn *button = [[GoodBtn alloc] init];
    button.titleLabel.font = [UIFont systemFontOfSize:13];
    button.frame = CGRectMake(0, 0, IMAGE.size.width/2, IMAGE.size.height/2);
    button.backgroundColor = [UIColor clearColor];
    [button setBackgroundImage:IMAGE forState:UIControlStateNormal];
    return button;
}
+(UIView*)view:(UIView*)view title:(NSString*)title addTarget:(id)target{
    
    UIView *bg = [[UIView alloc] initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH, SCREEN_HEIGHT-20)];
    [view addSubview:bg];
    
    UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
    [activityView startAnimating];
    bg.backgroundColor = RGB(0, 0, 0, .4);
    [bg addSubview:activityView];
    activityView.frame = CGRectMake((bg.frame.size.width-25)/2-55, (bg.frame.size.height-25)/2, 25, 25);
    
    GoodLabel *label = [GoodLabel labelWithFont:14 title:title];
    label.frame = CGRectMake((bg.frame.size.width-25)/2-25, (bg.frame.size.height-25)/2, FW(bg), 20);
    [bg addSubview:label];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button addTarget:target action:@selector(cancelPressed) forControlEvents:UIControlEventTouchUpInside];
    button.frame = CGRectMake((bg.frame.size.width-100)/2, (bg.frame.size.height-25)/2+30, 100, 35);
    [button setTitle:STR(@"取消") forState:UIControlStateNormal];
    if ([Global curLanguageEn]) {
        [button setTitle:@"Cancel" forState:UIControlStateNormal];
    }
    [bg addSubview:button];
    
    
    return bg;
}
@end
